home *** CD-ROM | disk | FTP | other *** search
- App WimpWindow
- In -
- Out WimpWin
- Type Module
- Ver 1.02g
-
- Define Module
- Name WimpWindow
- Author Justin Fletcher
- SWIs
- Prefix WimpWindow
- Base &90340
- 0 Colour swi_colour
- 1 TitleFlags swi_titleflags
- 2 WorkFlags swi_workflags
- 3 SpriteArea swi_spritearea
- 4 MinWidth swi_minwidth
- 5 MinHeight swi_minheight
- 6 TitleData swi_titledata
- 7 WindowFlags swi_windowflags
- End SWIs
- Workspace 4
- Init init
- End Module
-
- Pre
- #Cond AllowExternal Do you want external tasks to access windows
- End Pre
-
- #REM Off
- ; *******************************************************************
- ; Subroutine: init
- ; Description: Check the RO version and create an offset for the
- ; later ones
- ; Parameters: none
- ; Returns: none
- ; *******************************************************************
- .init
- STMFD (sp)!,{r0-r5,link} ; Stack registers
- XSWI "OS_Module",18,^$`name
- LDR r1,[r3,#&14] ; offset to help string
- ADD r1,r1,r3 ; pointer to help string
- $textloop
- LDRB r0,[r1],#1 ; read byte and increment
- CMP r0,#9 ; until we get to a tab
- BNE $textloop ; go around again
- LDRB r0,[r1,#2] ; read the sub version ie #.x#
- CMP r0,#ASC("6") ; is this version 3.6x ?
- ; this will die when ro4 comes out!
- MOVGE r0,#8 ; offset of 8
- MOVLT r0,#0 ; no offset
- STR r0,[r12] ; store in private space
- LDMFD (sp)!,{r0-r5,pc} ; Return from call
-
- $`name
- EQUZA "WindowManager"
-
- ; *******************************************************************
- ; Subroutine: check_r0_valid
- ; Description: Checks that r0 is a valid window handle
- ; Parameters: r0-> window handle
- ; Returns: VS and r0-> error block if invalid
- ; *******************************************************************
- .check_r0_valid
- STMFD (sp)!,{r0-r2,link} ; Stack registers
- AND r1,r0,#3 ; read bottom two bytes
- CMP r1,#1 ; is b0 set ?
- BNE $notb0 ; if not, claim it's not a window
- BIC r0,r0,#1 ; clear b0
- LDR r1,[r0] ; read first word
- LDR r2,$`wind ; read marker
- CMP r1,r2 ; is it really a window ?
- BNE $notawindow ; if not, bounce out
- ; check the DomainID if not external tasks
- #Cond Of AllowExternal
- #Cond Else
- LDR r1,[r0,#4] ; read DomainId
- LMOV r2,#&FF8 ; address of DomainId
- LDR r2,[r2] ; read current DomainId
- ; REM "Owner %&1, Us %&2"
- CMP r1,r2 ; are they the same ?
- BNE $notyourwindow ; if not, push off
- #Cond End
- LDMFD (sp)!,{r0-r2,pc} ; Return from call
- $`wind
- EQUS "Wind" ; marker for window start
- $notb0
- ADR r0,$`notb0 ; error block
- $error
- ADD sp,sp,#4 ; skip r0
- LDMFD (sp)!,{r1-r2,link} ; Return from call
- ORRS pc,link,#vbit ; exit with V set
- $`notb0
- EQUD &400C1
- EQUZA "That is not a window - b0 not set"
-
- $notawindow
- ADR r0,$`notawindow ; error block
- B $error ; process error
- $`notawindow
- EQUD &400C1
- EQUZA "That is not a window - Window marker not present"
-
- #Cond Of AllowExternal
- #Cond Else
- $notyourwindow
- ADR r0,$`notyourwindow ; error block
- B $error ; process error
- $`notyourwindow
- EQUD &400C1
- EQUZA "That window does not belong to you"
- #Cond End
-
- ; *******************************************************************
- ; Subroutine: swi_colour
- ; Description: Sets the colour of a part of the window
- ; Parameters: r0-> window handle
- ; r1 = region
- ; 0 - frame foreground (&FF for none)
- ; 1 - frame background
- ; 2 - work foreground
- ; 3 - work background (&FF for none)
- ; 4 - scrollbar outer
- ; 5 - scrollbar inner
- ; 6 - when focused
- ; r2 = colour
- ; Returns: none, or VS and r0 if error
- ; *******************************************************************
- .swi_colour
- STMFD (sp)!,{r0-r2,link} ; Stack registers
- BL check_r0_valid ; is the window handle valid ?
- BVS $exit ; if not, exit with error
- CMP r1,#0 ; is this too low ?
- BLT $error ; if so, tell them
- CMP r1,#6 ; is this too high ?
- BGT $error ; if so, tell them
- BIC r0,r0,#1 ; clear b0
- ; **** RO Specific bit ****
- LDR link,[r12] ; read offset for RO version
- ADD r0,r0,link ; and add it to our pointer
- ; **** RO Specific bit ****
- ADD r1,r0,r1 ; add on the offset we're given
- STRB r2,[r1,#72+32] ; store colour in block
- LDR r1,[sp,#4] ; read the colour we changed
- CMP r1,#2 ; was it workarea fore ?
- CMPNE r1,#3 ; was it workarea back ?
- BEQ $workarea_redraw ; if so, redraw it
- BL redraw_tools ; redraw the tools
- $exit
- XLDMFD (sp)!,{r0-r2,pc} ; Return from call
- $workarea_redraw
- BL redraw_window ; redraw the whole window
- B $exit ; and exit nicely
- $error
- LDMFD (sp)!,{r0-r2,link} ; restore registers
- ADR r0,$`error ; error block
- ORRS pc,link,#vbit ; return with VSet
- $`error
- EQUD &400C1
- EQUZA "Tool type out of range"
-
- ; *******************************************************************
- ; Subroutine: swi_titleflags
- ; Description: Change the current title bar flags
- ; Parameters: r0-> window handle
- ; r1 = BIC value
- ; r2 = EOR value
- ; Returns: none, or VS and r0 if error
- ; *******************************************************************
- .swi_titleflags
- STMFD (sp)!,{r0-r3,link} ; Stack registers
- BL check_r0_valid ; is the window handle valid ?
- BVS $exit ; if not, exit with error
- BIC r0,r0,#1 ; clear b0
- ; **** RO Specific bit ****
- LDR link,[r12] ; read offset for RO version
- ADD r0,r0,link ; and add it to our pointer
- ; **** RO Specific bit ****
- LDR r3,[r0,#72+56] ; read the current settings
- BIC r3,r3,r1 ; clear bits specified
- EOR r3,r3,r2 ; and invert those others wanted
- TST r3,#(1<<6) ; is it anti-aliased ?
- BICEQ r3,r3,#(255<<24) ; if so, clear top bits
- BIC r3,r3,#(255<<16) ; clear top-mid bits
- BIC r3,r3,#(15<<12) ; clear icon type
- BIC r3,r3,#(%10100100) ; clear the bottom ignored bits
- STR r3,[r0,#72+56] ; store back in block
- BL redraw_tools ; redraw the tools
- $exit
- XLDMFD (sp)!,{r0-r3,pc} ; Return from call
-
-
- ; *******************************************************************
- ; Subroutine: swi_workflags
- ; Description: Change the work area button flags
- ; Parameters: r0-> window handle
- ; r1 = BIC value
- ; r2 = EOR value
- ; Returns: none, or VS and r0 if error
- ; *******************************************************************
- .swi_workflags
- STMFD (sp)!,{r0-r3,link} ; Stack registers
- BL check_r0_valid ; is the window handle valid ?
- BVS $exit ; if not, exit with error
- BIC r0,r0,#1 ; clear b0
- ; **** RO Specific bit ****
- LDR link,[r12] ; read offset for RO version
- ADD r0,r0,link ; and add it to our pointer
- ; **** RO Specific bit ****
- LDR r3,[r0,#72+60] ; read the current settings
- BIC r3,r3,r1 ; clear bits specified
- EOR r3,r3,r2 ; and invert those others wanted
- AND r3,r3,#(15<<12) ; leave just button flags
- STR r3,[r0,#72+60] ; store back in block
- $exit
- XLDMFD (sp)!,{r0-r3,pc} ; Return from call
-
-
- ; *******************************************************************
- ; Subroutine: swi_spritearea
- ; Description: Change the sprite area
- ; Parameters: r0-> window handle
- ; r1-> new area
- ; Returns: none, or VS and r0 if error
- ; *******************************************************************
- .swi_spritearea
- STMFD (sp)!,{r0-r1,link} ; Stack registers
- BL check_r0_valid ; is the window handle valid ?
- BVS $exit ; if not, exit with error
- BIC r0,r0,#1 ; clear b0
- ; **** RO Specific bit ****
- LDR link,[r12] ; read offset for RO version
- ADD r0,r0,link ; and add it to our pointer
- ; **** RO Specific bit ****
- STR r1,[r0,#72+64] ; store in block
- BL redraw_window ; redraw the whole window
- $exit
- XLDMFD (sp)!,{r0-r1,pc} ; Return from call
-
-
- ; *******************************************************************
- ; Subroutine: swi_minwidth
- ; Description: Change the minimum width
- ; Parameters: r0-> window handle
- ; r1-> min width
- ; Returns: none, or VS and r0 if error
- ; *******************************************************************
- .swi_minwidth
- STMFD (sp)!,{r0-r2,link} ; Stack registers
- BL check_r0_valid ; is the window handle valid ?
- BVS $exit ; if not, exit with error
- BIC r0,r0,#1 ; clear b0
- ; **** RO Specific bit ****
- LDR link,[r12] ; read offset for RO version
- ADD r0,r0,link ; and add it to our pointer
- ; **** RO Specific bit ****
- LDR r2,[r0,#72+68] ; read current word
- BIC r2,r2,#(255) ; clear bottom bits
- BIC r2,r2,#(255<<8) ; clear bottom other bits
- BIC r1,r1,#(255<<16) ; clear mid bits
- BIC r1,r1,#(255<<24) ; clear top bits
- ORR r1,r1,r2 ; merge
- STR r1,[r0,#72+68] ; store in block
- BL redraw_open ; redraw the window by opening
- $exit
- XLDMFD (sp)!,{r0-r2,pc} ; Return from call
-
- ; *******************************************************************
- ; Subroutine: swi_minheight
- ; Description: Change the minimum height
- ; Parameters: r0-> window handle
- ; r1-> max width
- ; Returns: none, or VS and r0 if error
- ; *******************************************************************
- .swi_minheight
- STMFD (sp)!,{r0-r2,link} ; Stack registers
- BL check_r0_valid ; is the window handle valid ?
- BVS $exit ; if not, exit with error
- BIC r0,r0,#1 ; clear b0
- ; **** RO Specific bit ****
- LDR link,[r12] ; read offset for RO version
- ADD r0,r0,link ; and add it to our pointer
- ; **** RO Specific bit ****
- LDR r2,[r0,#72+68] ; read current word
- BIC r2,r2,#(255<<16) ; clear mid bits
- BIC r2,r2,#(255<<24) ; clear top bits
- ORR r1,r2,r1,LSL #16 ; merge
- STR r1,[r0,#72+68] ; store in block
- BL redraw_open ; redraw the window by opening
- $exit
- XLDMFD (sp)!,{r0-r2,pc} ; Return from call
-
- ; *******************************************************************
- ; Subroutine: swi_titledata
- ; Description: Change the titledata
- ; Parameters: r0-> window handle
- ; r1-> titledata block
- ; Returns: none, or VS and r0 if error
- ; *******************************************************************
- .swi_titledata
- STMFD (sp)!,{r0-r4,link} ; Stack registers
- BL check_r0_valid ; is the window handle valid ?
- BVS $exit ; if not, exit with error
- BIC r0,r0,#1 ; clear b0
- ; **** RO Specific bit ****
- LDR link,[r12] ; read offset for RO version
- ADD r0,r0,link ; and add it to our pointer
- ; **** RO Specific bit ****
- LDMIA r1,{r2-r4} ; read 12 bytes
- ADD r1,r0,#72+72 ; find the title data address
- STMIA r1,{r2-r4} ; store in block
- BL redraw_tools ; redraw the whole window
- $exit
- XLDMFD (sp)!,{r0-r4,pc} ; Return from call
-
- ; *******************************************************************
- ; Subroutine: swi_windowflags
- ; Description: Change the window flags
- ; Parameters: r0-> window handle
- ; r1 = BIC value
- ; r2 = EOR value
- ; Returns: none, or VS and r0 if error
- ; *******************************************************************
- .swi_windowflags
- STMFD (sp)!,{r0-r3,link} ; Stack registers
- BL check_r0_valid ; is the window handle valid ?
- BVS $exit ; if not, exit with error
- BIC r0,r0,#1 ; clear b0
- ; **** RO Specific bit ****
- LDR link,[r12] ; read offset for RO version
- ADD r0,r0,link ; and add it to our pointer
- ; **** RO Specific bit ****
- LDR r3,[r0,#72+28] ; read the current settings
- BIC r3,r3,r1 ; clear bits specified
- EOR r3,r3,r2 ; and invert those others wanted
- STR r3,[r0,#72+28] ; store back in block
- BL redraw_open ; redraw the window by opening it
- $exit
- XLDMFD (sp)!,{r0-r3,pc} ; Return from call
-
- ; *******************************************************************
- ; Subroutine: redraw_tools
- ; Description: Redraw just the tool bars
- ; Parameters: r0-> window handle (b0 clear)
- ; Returns: none
- ; *******************************************************************
- .redraw_tools
- STMFD (sp)!,{r0-r6,link} ; Stack registers
- MOV r6,r0 ; use r5 as base of block
- ; **** RO Specific bit ****
- ; only needed because we've already
- ; added the offset on...
- LDR r5,[r12] ; read the offset for 'far' blocks
- SUB r5,r0,r5 ; and reduce it
- ; **** RO Specific bit ****
- ; title bar
- LDR r1,[r5,#28] ; left of window (inc tools)
- LDR r2,[r6,#72+12] ; top of window (exc tools)
- LDR r3,[r5,#36] ; right of window (inc tools)
- LDR r4,[r5,#40] ; top of window (inc tools)
- XSWI "XWimp_ForceRedraw",-1 ; redraw whole window
- ; right scroll bar
- LDR r1,[r6,#72+8] ; right of window (exc tools)
- LDR r2,[r5,#32] ; bottom of window (inc tools)
- LDR r3,[r5,#36] ; right of window (inc tools)
- LDR r4,[r5,#40] ; top of window (inc tools)
- XSWI "XWimp_ForceRedraw",-1 ; redraw whole window
- ; bottom scroll bar
- LDR r1,[r5,#28] ; left of window (inc tools)
- LDR r2,[r5,#32] ; bottom of window (inc tools)
- LDR r3,[r5,#36] ; right of window (inc tools)
- LDR r4,[r6,#72+4] ; bottom of window (exc tools)
- XSWI "XWimp_ForceRedraw",-1 ; redraw whole window
- XLDMFD (sp)!,{r0-r6,pc} ; Return from call
-
- ; *******************************************************************
- ; Subroutine: redraw_window
- ; Description: Redraw the entire window
- ; Parameters: r0-> window handle (b0 clear)
- ; Returns: none
- ; *******************************************************************
- .redraw_window
- STMFD (sp)!,{r0-r4,link} ; Stack registers
-
- ; **** RO Specific bit ****
- ; only needed because we've already
- ; added the offset on...
- LDR link,[r12] ; read the offset for 'far' blocks
- SUB r0,r0,link ; and reduce it
- ; **** RO Specific bit ****
-
- LDR r1,[r0,#28] ; left of window (inc tools)
- LDR r2,[r0,#32] ; bottom of window (inc tools)
- LDR r3,[r0,#36] ; right of window (inc tools)
- LDR r4,[r0,#40] ; top of window (inc tools)
- XSWI "XWimp_ForceRedraw",-1 ; redraw whole window
- XLDMFD (sp)!,{r0-r4,pc} ; Return from call
-
- ; *******************************************************************
- ; Subroutine: redraw_open
- ; Description: Redraw the window by re-opening it
- ; Parameters: r0-> window block (b0 unset)
- ; Returns: none
- ; *******************************************************************
- .redraw_open
- #Cond Of AllowExternal
- STMFD (sp)!,{r0-r3,link} ; Stack registers
- REM "Sending message to open window"
- XBL claim,36 ; claim space for block
- MOV r1,r0 ; r1 = claimed block
- LDR r0,[sp] ; re-read window block
-
- ; **** RO Specific bit ****
- ; only needed because we've already
- ; added the offset on...
- LDR link,[r12] ; read the offset for 'far' blocks
- SUB r0,r0,link ; and reduce it
- ; **** RO Specific bit ****
-
- ADD r2,r0,#1 ; re-assert window handle
- STR r2,[r1] ; store in claimed block
- SWI "XWimp_GetWindowState" ; read current state
- XSWI "XWimp_SendMessage",2 ; send the message to open window
- XBL release,r1 ; release the space
- LDR r0,[sp] ; re-read window block
-
- ; **** RO Specific bit ****
- ; only needed because we've already
- ; added the offset on...
- LDR link,[r12] ; read the offset for 'far' blocks
- SUB r0,r0,link ; and reduce it
- ; **** RO Specific bit ****
-
- BL redraw_tools ; and redraw the tools too
- LDMFD (sp)!,{r0-r3,pc} ; Return from call
- #Cond Else
- STMFD (sp)!,{r0-r1,link} ; Stack registers
- XBL claim,36 ; claim space for block
- MOV r1,r0 ; r1 = claimed block
- LDR r0,[sp] ; re-read window block
-
- ; **** RO Specific bit ****
- ; only needed because we've already
- ; added the offset on...
- LDR link,[r12] ; read the offset for 'far' blocks
- SUB r0,r0,link ; and reduce it
- ; **** RO Specific bit ****
-
- ADD r0,r0,#1 ; re-assert r0
- STR r0,[r1] ; store in claimed block
- SWI "XWimp_GetWindowState" ; read current state
- SWI "XWimp_OpenWindow" ; open the window
- XBL release,r1 ; release the space
- LDR r0,[sp] ; re-read window block
-
- ; **** RO Specific bit ****
- ; only needed because we've already
- ; added the offset on...
- LDR link,[r12] ; read the offset for 'far' blocks
- SUB r0,r0,link ; and reduce it
- ; **** RO Specific bit ****
-
- BL redraw_tools ; redraw the tools too
- LDMFD (sp)!,{r0-r1,pc} ; Return from call
- #Cond End
-
- #library "Memory",claim.release
- #Here libraries
- #Post
- #Run <CODE>
-